package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class homework1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //缓冲流实现文件的复制------CopyDemo3Buffered
//        FileInputStream fis=new FileInputStream("tupian.jpg");
//        BufferedInputStream bis=new BufferedInputStream(fis);
//        FileOutputStream fos=new FileOutputStream("tupaincp2.jpg");
//        BufferedOutputStream bos=new BufferedOutputStream(fos);
//        int d;
//        while((d=bis.read())!=-1){
//            bos.write(d);
//        }
//        System.out.println("复制完毕");
//        bis.close();
//        bos.close();



        //对象流读写对象---------------Student+OOSDemo+OISDemo
//        String name="mjh";
//        int age=55;
//        String ganser="男";
//        String  [] otherInfo={"唱","跳","rap","篮球"};
//        Student stu=new Student(name,age,ganser,otherInfo);
//        FileOutputStream fos=new FileOutputStream("student1.txt");
//        ObjectOutputStream oos=new ObjectOutputStream(fos);
//        System.out.println(stu);
//
//        oos.writeObject(stu);
//        System.out.println("写入完毕");
//        oos.close();

//        FileInputStream fis=new FileInputStream("student1.txt");
//        ObjectInputStream ois=new ObjectInputStream(fis);
//       Object ob =ois.readObject();
//       Student zs=(Student) ob;
//        System.out.println(zs);
//        ois.close();


        //转换流读写字符---------------OSWDemo+ISRDemo
//        FileOutputStream fos=new FileOutputStream("ge.txt");
//        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
//        osw.write("dawhdauwdhawui");
//        osw.write(",ndiauwhdiuaw");
//        System.out.println("写入完毕");
//        osw.close();

        FileInputStream fis=new FileInputStream("ge.txt");
        InputStreamReader isr=new InputStreamReader(fis,StandardCharsets.UTF_8);
        int d;
        while((d=isr.read())!=-1){
            System.out.print((char)d);
        }
        isr.close();








































    }
}
